#include <iostream>
#include <set>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    multiset<int> L;
    multiset<int>::iterator it;
    int n,x,i,pre,later,a;
    cin>>n;
    cin>>x;
    cout<<x<<" ";
    L.insert(x);
    for(i=1;i<n;i++)
    {
        cin>>x;
        L.insert(x);
        it=L.lower_bound(x);
        if(it==L.begin())
        {
            it++;
            cout<<*it<<" ";
            continue;
        }
       it++;
       if(it==L.end())
        {
            it--;
            it--;
            cout<<*it<<" ";
            continue;
        }
       else
        {
            later=*it;
            it--;
            a=*it;
            it--;
            pre=*it;
        if(a-pre>=later-a)
            {
                cout<<later<<" ";
            }
            else
            {
               cout<<pre<<" ";
            }
        }
    }
    cout << endl;
    return 0;
}
